<!--钢筋保护层检测---钢筋保护层检测-1---编辑-->
<template>
  <div class="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group
            v-model="radio"
            size="small"
            @change="modelType($event)"
          >
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
            <!-- #2b5a9d -->
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button
              type="primary"
              v-if="getList.modelType == 0 && yj_add == true"
              icon="el-icon-circle-plus-outline"
              size="small"
              @click="engineerings(0)"
              >新增</el-button
            >

            <el-button
              type="primary"
              v-if="getList.modelType == 0 && yj_edit == true"
              icon="el-icon-edit"
              size="small"
              @click="engineerings(1)"
              >编辑</el-button
            >
            <el-button
              type="primary"
              v-if="getList.modelType == 0 && yj_submit == true"
              icon="el-icon-circle-check"
              size="small"
              @click="SubmitText(equipmentDetailId)"
              >提交
            </el-button>
            <el-button
              type="primary"
              v-if="getList.modelType == 0 && yj_delete == true"
              icon="el-icon-delete"
              size="small"
              @click="rowDelete(equipmentDetailId)"
              >删除
            </el-button>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <div class="text_table mechanism_Table">
        <el-table
          ref="multipleTable"
          :data="tableData"
          style="width: 100%"
          height="100%"
          default-expand-all
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
          row-key="F_CompanyId"
          v-loading="loading"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
          :row-class-name="tableRowClassName"
          border
          stripe
          highlight-current-row
          @current-change="handleCurrentChange"
          @row-click="getRowInfo"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="F_CompanyId"
            label="工程编号"
            width="260"
            style="display: flex"
          >
            <template slot-scope="scope">
              <a href="javascript:;" :title="scope.row.F_CompanyId">{{
                scope.row.F_CompanyId
              }}</a>
            </template>
          </el-table-column>
          <el-table-column prop="F_ShortName" label="工程名称" width="290">
            <template slot-scope="scope">
              <a href="javascript:;" :title="scope.row.F_ShortName">{{
                scope.row.F_ShortName
              }}</a>
            </template>
          </el-table-column>
          <el-table-column prop="F_Nature" label="工程类别" width="140">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.F_Nature">{{
                  scope.row.F_Nature
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="F_Note"
            label="回弹设计值"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="cous"
            label="回弹任务数"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="iscous"
            label="回弹完成数"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="price"
            label="回弹完成率"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="F_CheckType"
            label="检测类型"
            width="100"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="F_LeaderCompanyName"
            label="检测单位"
            width="130"
            align="center"
          >
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.F_LeaderCompanyName">{{
                  scope.row.F_LeaderCompanyName
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="F_TestDate"
            label="回弹检测时间"
            width="100"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="F_IsTrue"
            label="回弹检测结果"
            width="100"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="F_CreateUserName"
            label="记录人"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="F_Status"
            label="信息状态"
            width="80"
            align="center"
          >
          </el-table-column>

          <template slot="empty">
            <img
              style="width: 285px; height: 208px"
              src="@/assets/img/undata.png"
              alt=""
            />
            <div class="pageFlagText">暂时没有数据哦！</div>
          </template>
        </el-table>
      </div>
      <!-- 按检测记录新增/编辑 -->
      <div class="fvisibles">
        <el-dialog
          :close-on-click-modal="false"
          :title="dialogText"
          v-dialogDrag
          :visible.sync="dialogTableVisible"
          @close="close"
          v-loading="loadingDialog"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div class="" :style="{ height: dialogHeightSample }">
            <el-form :model="formData" :rules="rulesSample" ref="formData">
              <div style="display: flex; width: 100%; margin-top: 15px">
                <el-form-item
                  label="检测类型"
                  prop="fChecktype"
                  :label-width="formLabelWidth"
                >
                  <!-- <el-input v-model="formData.fChecktype" autocomplete="off" placeholder="请输入"></el-input> -->
                  <el-select
                    :disabled="dis"
                    @change="function (item) {
                        return handleChangeSelectId(item);
                      }
                    "
                    v-model="formData.fChecktype"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(v, i) in Checktype"
                      :key="i"
                      :label="v.fItemName"
                      :value="v"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="检测单位"
                  prop="fLeadercompanyname"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    disabled
                    v-model="formData.fLeadercompanyname"
                    autocomplete="off"
                    placeholder="请输入"
                  >
                  </el-input>
                </el-form-item>
              </div>
              <div style="display: flex; width: 100%">
                <el-form-item
                  label="回弹检测时间"
                  prop="fTestdates"
                  :label-width="formLabelWidth"
                >
                  <!-- <el-input v-model="formData.fTestdates" autocomplete="off" placeholder="请输入"></el-input> -->
                  <el-date-picker
                    :disabled="dis"
                    format="yyyy/MM/dd"
                    value-format="yyyy-MM-dd"
                    v-model="formData.fTestdates"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>

                <el-form-item
                  label="回弹检测结果"
                  prop="fIstrue"
                  :label-width="formLabelWidth"
                >
                  <!-- <el-input v-model="formData.fIstrue" autocomplete="off"></el-input> -->
                  <el-select
                    :disabled="dis"
                    v-model="formData.fIstrue"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(v, i) in IstrueData"
                      :key="i"
                      :label="v.fItemName"
                      :value="v.fItemName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>

              <div style="display: flex; width: 100%">
                <el-form-item
                  label="检测情况概述"
                  prop="fNote"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    :disabled="dis"
                    v-model="formData.fNote"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <!--   -->
                <el-form-item
                  label="记录人"
                  prop="fCreateusername"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    disabled
                    v-model="formData.fCreateusername"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </div>
              <div style="display: flex; width: 100%">
                <!--   -->
                <el-form-item
                  label="回弹记录表"
                  prop="fCreateusername"
                  :label-width="formLabelWidth"
                  class="enclosure"
                  style="height: 100%"
                >
                  <el-input
                    v-show="false"
                    v-model="formData.fCreateusername"
                    autocomplete="off"
                  >
                  </el-input>
                  <div
                    ref="fPhotofilelist"
                    style="
                      height: 25px;
                      line-height: 25px;
                      width: 100%;
                      display: flex;
                      border: 1px solid #d1d7e2;
                      border-radius: 5px;
                      margin: 8px 0 2px 0;
                    "
                  >
                    <div
                      v-for="(v, i) in fPhotofilelist"
                      :key="i"
                      style="margin: 2px 3px; height: 87%"
                      @click="openPdfs(v)"
                    >
                      <img
                        style="max-width: 100%; max-height: 100%"
                        src="@/assets/img/pdf.png"
                      />
                      <!-- <img
                        src="@/assets/img/enclosure/imgs.png"
                        alt=""
                        style="height: 90%"
                                          /> -->
                    </div>
                  </div>
                  <el-button
                    v-show="!dis"
                    type="primary"
                    icon="el-icon-search"
                    size="small"
                    @click="operation('1')"
                    style="margin: 8px 0 2px 3px"
                    >操作</el-button
                  >
                </el-form-item>
                <!--   -->
                <el-form-item
                  label="回弹检测报告"
                  prop="fCreateusername"
                  :label-width="formLabelWidth"
                  class="enclosure"
                  style="height: 100%"
                >
                  <el-input
                    v-show="false"
                    v-model="formData.fCreateusername"
                    autocomplete="off"
                  >
                  </el-input>
                  <div
                    ref="fSourcefilelist"
                    style="
                      height: 25px;
                      line-height: 25px;
                      width: 100%;
                      display: flex;
                      border: 1px solid #d1d7e2;
                      border-radius: 5px;
                      margin: 8px 0 2px 0;
                    "
                  >
                    <div
                      v-for="(v, i) in fSourcefilelist"
                      :key="i"
                      style="margin: 2px 3px; height: 87%"
                      @click="openPdfs(v)"
                    >
                      <img
                        style="max-width: 100%; max-height: 100%"
                        src="@/assets/img/pdf.png"
                      />
                      <!-- <img
                        src="@/assets/img/enclosure/imgs.png"
                        alt=""
                        style="height: 90%"
                                          /> -->
                    </div>
                  </div>
                  <el-button
                    v-show="!dis"
                    type="primary"
                    icon="el-icon-search"
                    size="small"
                    @click="operation('2')"
                    style="margin: 8px 0 2px 3px"
                    >操作</el-button
                  >
                </el-form-item>
              </div>
            </el-form>
          </div>

          <div style="height: 40px" v-if="flagNum == 0">
            <div style="position: absolute; right: 5px; bottom: 0">
              <el-button type="primary" @click="submitForm(formData)"
                >保存</el-button
              >
              <el-button type="warning" @click="resetForm('formData')"
                >重置</el-button
              >
            </div>
          </div>
        </el-dialog>
      </div>
      <!-- 上传附件  -->
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog
          title="上传附件"
          v-dialogDrag
          top="-17vh"
          :visible.sync="dialogTableVisibleTexts"
          v-loading="loadingDialogTexts"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div class="dialogBody common" :style="{ height: '240px' }">
            <el-upload
              action="action"
              ref="upload"
              list-type="picture-card"
              :file-list="fPhotofilelist"
              :auto-upload="false"
              :on-change="handleChange"
              accept=".pdf"
            >
              <i slot="default" class="el-icon-plus"></i>
              <div
                style="width: 100%; height: 100%; text-align: center"
                slot="file"
                slot-scope="{ file }"
              >
                <div
                  style="
                    width: 100%;
                    height: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                  "
                  class="images"
                >
                  <img
                    style="max-width: 100%; max-height: 100%"
                    src="@/assets/img/pdf.png"
                  />
                </div>
                <span class="el-upload-list__item-actions">
                  <span
                    title="文件预览"
                    class="el-upload-list__item-preview"
                    @click="openPdf(file)"
                  >
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span
                    title="删除文件"
                    class="el-upload-list__item-delete"
                    @click="handleRemove(file)"
                  >
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload(enclosureImg)"
                  >保存</el-button
                >
                <el-button type="warning" @click="resetFormv()">关闭</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog
          title="上传附件"
          v-dialogDrag
          top="-17vh"
          :visible.sync="dialogTableVisibleTexts1"
          v-loading="loadingDialogTexts1"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div class="dialogBody common" :style="{ height: '240px' }">
            <el-upload
              action="action"
              ref="upload1"
              list-type="picture-card"
              :file-list="fSourcefilelist"
              :auto-upload="false"
              :on-change="handleChange1"
              accept=".pdf"
            >
              <i slot="default" class="el-icon-plus"></i>
              <div
                style="width: 100%; height: 100%; text-align: center"
                slot="file"
                slot-scope="{ file }"
              >
                <div
                  style="
                    width: 100%;
                    height: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                  "
                  class="images"
                >
                  <img
                    style="max-width: 100%; max-height: 100%"
                    src="@/assets/img/pdf.png"
                  />
                </div>
                <span class="el-upload-list__item-actions">
                  <span
                    title="文件预览"
                    class="el-upload-list__item-preview"
                    @click="openPdf(file)"
                  >
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span
                    title="删除文件"
                    class="el-upload-list__item-delete"
                    @click="handleRemove(file)"
                  >
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload1(enclosureImg)"
                  >保存</el-button
                >
                <el-button type="warning" @click="resetForms()">关闭</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
      <div class="Control-2">
        <el-dialog :title="fFileName" v-dialogDrag :visible.sync="dialogPdf">
          <div :style="{ height: dialogHeights }">
            <iframe
              :src="pdfUrl"
              width="100%"
              height="100%"
              frameborder="0"
            ></iframe>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getConcreteChecksampleEasyTestList, // 混凝土回弹业务监管-2-列表页
  upload,
  getCheckTypeByUserList, //检测类型
  getConcreteChecksampleEasyTestByFid, // 混凝土回弹业务监管-2-详情接口

  // getConcreteChecksamplePageList,
  saveConcreteChecksampleEasyTest, // 混凝土回弹业务监管-新增接口
  delConcreteChecksampleEasyTest, //删除
  submitConcreteChecksampleEasyTest, //提交
} from "@/api/request.js";

export default {
  inject: ["reload"],
  name: "Home",
  data() {
    return {
      name: "Control-2Text",
      lr_look: null,
      yj_add: null,
      yj_edit: null,
      yj_delete: null,
      yj_submit: null,
      fnote: "", //回弹设计值是否为空，为空不可新增
      fstatus: "", //信息状态，为空可新增，未提交时可编辑、提交、删除
      formLabelWidth: "85px",
      dialogTableVisibleTexts: false,
      dialogTableVisibleTexts1: false,
      timestamp1: null,
      timestamp2: null,
      operationNum: null,
      enclosureImg: {},
      fPhotofilelist: [],
      fSourcefilelist: [],

      loadingDialogTexts: false,
      loadingDialogTexts1: false,
      IstrueData: [
        {
          fItemCode: null,
          fItemName: "合格",
        },
        {
          fItemCode: null,
          fItemName: "不合格",
        },
      ], //是否合格
      dialogPdf: false,
      pdfUrl: "",
      fFileName: "",
      equipmentDetailId: null, //列表页id
      dis: false,
      fProjecttypeid: null,

      imgsFId: {
        fId: null, //文件id
      },
      imgsFId1: {
        fId: null, //文件id
      },
      flagNum: 0,
      Checktype: [], //检测类型 - 根据当前登录用户获取检测类型
      dateMo: null, //默认日期

      disabledText: true,
      queryCriteriaData: {},
      dialogHeightSample: "",
      formData: {
        fId: "", //主鍵id
        fProjectid: "", //项目id
        fProjectname: "", //项目简称
        fCompanyname: "", //施工/委托单位简称
        fCompanyid: "", //施工/委托单位id
        fChecktype: "", //检测类型
        fLeadercompanyid: "", //检测单位id
        fLeadercompanyname: "", //检测单位简称
        fTestdates: "", //回弹检测时间
        fIstrue: "", //回弹检测结果
        fProjecttypeid: "", //工程部位id
        fNote: "", //检测情况概述
        fSourcefile: "", //回弹检测报告id
        fPhotofile: "", //回弹记录表id
        fIsconcrete: null,
        userId: "", //记录人id
        userName: "", //记录人
        recordfiles: [], //删除文件id集合--修改时传
      },
      rulesSample: {
        fChecktype: [
          { required: true, message: "请选择检测类型", trigger: "change" },
        ],
        fLeadercompanyname: [
          { required: true, message: "请输入检测单位", trigger: "blur" },
        ],
        fTestdates: [
          { required: true, message: "请选择回弹检测时间", trigger: "change" },
        ],
        fIstrue: [
          { required: true, message: "请选择回弹检测结果", trigger: "change" },
        ],
        fCreateusername: [{ required: true, message: "请选择回弹检测结果" }],
        fPhotofilelist: [{ required: true, message: "请选择回弹记录表" }],
        fSourcefilelist: [{ required: true, message: "请选择回弹检测报告" }],
      },
      // 样品信息
      // 按工程划分新增
      dialogTableVisibleDivide: false,
      loadingDialogDivide: false,

      tableData5: [],
      radio: "待办",
      dialogHeight: "",
      dialogHeights: "",
      fId: null, //当前数据fId
      loading: false,

      userInfo: {}, //登录用户
      // 列表
      getList: {
        modelType: "0", // 0代办 1已办  2查询页面
        companyId: "", //机构id
        userId: "", //当前登录用户id
      },
      // 新增/编辑
      dialogText: "",
      dialogTableVisible: false,
      loadingDialog: false,
      row: null,
      tableData: [], //表格数据列表
      dialogVisible: false,
    };
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
    this.getList.userId = this.userInfo.userId;
    this.getList.companyId = this.userInfo.companyId;
    this.formData.userId = this.userInfo.userId;
    this.formData.userName = this.userInfo.realName;
    this.formData.fCreateusername = this.userInfo.realName;
  },
  mounted() {
    this.getDate();

    this.btnRole(this.name);
    this.getCheckTypeByUserList(); //检测类型 - 根据当前登录用户获取检测类型

    this.getHeight();
    this.getDataList(this.getList);
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("GxBack-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        this.yj_add = btnStr.includes("yj_add");

        this.yj_edit = btnStr.includes("yj_edit");
        this.yj_delete = btnStr.includes("yj_delete");
        this.yj_submit = btnStr.includes("yj_submit");
      } else {
        // this.lr_look = true;
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        this.yj_submit = true;
      }
    },
    close() {
      // this.reload()
    },
    // 检测类型 - change
    handleChangeSelectId(item) {
      this.formData.fChecktype = item.fItemName; //检测类型
      this.formData.fLeadercompanyname = item.fCompanyName; //检测单位简称
      this.formData.fLeadercompanyid = item.fCompanyId; //检测单位id
    },
    // 检测类型 - 根据当前登录用户获取检测类型
    getCheckTypeByUserList() {
      getCheckTypeByUserList({ companyId: this.getList.companyId })
        .then((res) => {
          if (res.errcode == 0) {
            this.Checktype = res.data.Checktype;
          } else {
            this.$message.error("检测类型", res.msg);
          }
        })
        .catch(() => {
          console.log("检测类型");
        });
    },
    // 操作按钮
    operation(num) {
      this.operationNum = num;
      if (num == 1) {
        this.dialogTableVisibleTexts = true;

        this.$refs.fPhotofilelist.style.border = "1px solid #DCDFE6";
      } else if (num == 2) {
        this.$refs.fSourcefilelist.style.border = "1px solid #DCDFE6";
        this.dialogTableVisibleTexts1 = true;
      }
    },
    openPdf(file) {
      this.dialogPdf = true;
      this.pdfUrl = file.url;
      this.fFileName = file.name;
    },
    submitUpload() {
      this.dialogTableVisibleTexts = false;
    },
    submitUpload1() {
      this.dialogTableVisibleTexts1 = false;
    },
    // 移除
    handleRemove(file) {
      if (this.operationNum == 1) {
        this.$refs.upload.handleRemove(file);
        for (let index = 0; index < this.fPhotofilelist.length; index++) {
          if (file.uid == this.fPhotofilelist[index].uid) {
            if (this.fPhotofilelist[index].atta == undefined) {
              this.formData.recordfiles.push({
                fId: this.fPhotofilelist[index].fId,
              });
            } else {
              this.formData.recordfiles.push({
                fId: this.fPhotofilelist[index].atta.fId,
              });
            }
            this.fPhotofilelist.splice(index, 1);
          }
        }
      } else if (this.operationNum == 2) {
        this.$refs.upload1.handleRemove(file);
        for (let index = 0; index < this.fSourcefilelist.length; index++) {
          if (file.uid == this.fSourcefilelist[index].uid) {
            // this.imgsFId1.fId = this.fSourcefilelist[index].atta.fId;
            if (this.fSourcefilelist[index].atta == undefined) {
              this.formData.recordfiles.push({
                fId: this.fSourcefilelist[index].fId,
              });
            } else {
              this.formData.recordfiles.push({
                fId: this.fSourcefilelist[index].atta.fId,
              });
            }
            this.fSourcefilelist.splice(index, 1);
          }
        }
      }
    },
    resetForm(formData) {
      this.$refs[formData].resetFields();
    },
    openPdfs(v) {
      this.dialogPdf = true;
      this.pdfUrl = v.url;
      this.fFileName = v.name;
    },
    // 上传文件
    handleChange(res) {
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("folderid", this.timestamp1); //将file属性添加到formData里

      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里

      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;
        this.fPhotofilelist.push(i[0]);
      });
    },
    handleChange1(res) {
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("folderid", this.timestamp2); //将file属性添加到formData里
      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里
      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;
        this.fSourcefilelist.push(i[0]);
      });
    },
    // 点击当前行变色
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    openDialog1(row) {
      this.dialogCheckVisible = true;
      this.getCheckList(row.F_EnCode);
    },
    tableRowClassName({ row }) {
      if (row.level == 0 && !row.children) {
        return "fristColor";
      }
    },
    getDetail() {
      if (this.equipmentDetailId != null && this.equipmentDetailId != "") {
        this.flagNum = 1;
        this.edit(1);
        this.dis = true;
      } else {
        return this.$message.error("请先选择需要编辑的数据");
      }
    },

    // 获取当前日期

    getDate() {
      var time = new Date();
      const y = time.getFullYear();
      var m = time.getMonth() + 1 + "";
      m = (m < 10 ? "0" : "") + m;
      var d = time.getDate() + "";
      d = (d < 10 ? "0" : "") + d;
      this.dateMo = `${y}-${m}-${d}`;
    },

    modelType(e) {
      this.fId = "";
      this.row = "";
      if (e == "待办") {
        this.flagNum = 0;
        this.getList.modelType = "0";
        this.disabledText = false;
      } else {
        this.flagNum = 1;
        this.getList.modelType = "1";
        this.disabledText = true;
      }
      this.getDataList(this.getList);
    },
    tranListToTreeData1(data) {
      let result = [];
      if (!Array.isArray(data)) {
        return result;
      }
      // 清除已存在的children 重新赋值
      data.forEach((item) => {
        delete item.children;
      });

      let map = {};
      data.forEach((item) => {
        map[item.F_CompanyId] = item;
      });

      data.forEach((item) => {
        let parent = map[item.F_ParentId];
        if (parent) {
          (parent.children || (parent.children = [])).push(item);
        } else {
          result.push(item);
        }
      });

      return result;
    },
    // 获取列表数据
    getDataList(data) {
      this.loading = true;
      // 混凝土回弹业务监管-2-列表页
      getConcreteChecksampleEasyTestList(data)
        .then((res) => {
          this.companyTree = res.data.checkConcretesampleEasyTestList;
          if (res.errcode == 0) {
            var that = this;
            setTimeout(() => {
              that.loading = false;
              that.tableData = that.tranListToTreeData1(that.companyTree);
              that.$nextTick(() => {
                that.$refs.multipleTable.doLayout();
              });
            }, 200);
          } else {
            this.$message.error("获取列表数据失败", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("获取列表数据接口报错");
          this.loading = false;
        });
    },

    // 新增/编辑
    edit(num) {
      // 样品信息

      if (num == 0) {
        this.disabledText = true;

        // 按检测记录新增
        this.formData.fId = "";

        this.formData.fProjectid = this.userInfo.projectId; //工程名称id
        this.formData.fProjectname = this.userInfo.projectName; //工程名称简称
        // this.formData.fProjectfullname = this.userInfo.projectName;//工程名称全称
        // this.formData.fCompanyfullname = this.userInfo.companyFullName//施工/委托单位全程
        this.formData.fCompanyname = this.userInfo.companyName; //施工/委托单位简称
        this.formData.fCompanyid = this.userInfo.companyId; //施工/委托单位id

        this.dialogText = "新增回弹信息";

        this.dialogTableVisible = true;
      } else {
        // 编辑
        if (this.equipmentDetailId != null && this.equipmentDetailId != "") {
          this.formData.fId = this.equipmentDetailId;
          this.dialogText = "编辑";
          this.dialogTableVisible = true;
          this.loadingDialog = true;
          this.recordData = [];
          this.recordData1 = [];

          getConcreteChecksampleEasyTestByFid({
            fId: this.equipmentDetailId,
          })
            .then((res) => {
              if (res.errcode == 0) {
                this.loadingDialog1 = false;
                this.loadingDialog = false;
                this.formData = res.data.lrCheckConcreteeasytest;
                this.formData.fSourcefile =
                  res.data.lrCheckConcreteeasytest.fSourcefile;
                this.formData.fPhotofile =
                  res.data.lrCheckConcreteeasytest.fPhotofile;
                this.timestamp1 = res.data.lrCheckConcreteeasytest.fPhotofile;
                this.timestamp2 = res.data.lrCheckConcreteeasytest.fSourcefile;
                this.fPhotofilelist = res.data.fPhotofilelist; //检测记录表文件集合
                this.fSourcefilelist = res.data.fSourcefilelist; //强度检测报告文件集合
                this.formData.recordfiles = [];
              } else {
                this.$message.error("编辑", res.msg);
                this.loadingDialog1 = false;
              }
            })
            .catch(() => {
              console.log("编辑");
              this.loadingDialog1 = false;
            });
        } else {
          return this.$message.error("请先选择需要编辑的数据");
        }
      }
    },

    // 选工程划分新增
    engineerings(num) {
      this.dis = false;
      this.formData = {
        fId: "", //主鍵id
        fProjectid: "", //项目id
        fProjectname: "", //项目简称
        fCompanyname: "", //施工/委托单位简称
        fCompanyid: "", //施工/委托单位id
        fChecktype: "", //检测类型
        fLeadercompanyid: "", //检测单位id
        fLeadercompanyname: "", //检测单位简称
        fCreateusername: this.userInfo.realName,
        fTestdates: this.dateMo, //回弹检测时间
        fProjecttypeid: this.fProjecttypeid,
        fIstrue: "", //回弹检测结果
        fNote: "", //检测情况概述
        fSourcefile: "", //回弹检测报告id
        fPhotofile: "", //回弹记录表id
        fIsconcrete: null,
        userId: this.userInfo.userId, //记录人id
        userName: this.userInfo.realName, //记录人
        recordfiles: [], //删除文件id集合--修改时传
      };
      if (num == 0) {
        this.fPhotofilelist = [];
        this.fSourcefilelist = [];

        if (this.fnote != "" && this.fstatus == "") {
          this.flagNum = 0;
          this.timestamp1 = "file1" + Date.parse(new Date());
          this.timestamp2 = "file2" + Date.parse(new Date());
          this.formData.fSourcefile = this.timestamp1;
          this.formData.fPhotofile = this.timestamp2;

          this.disabledText = true;

          this.edit(0);
        } else {
          this.$message.error("请选择指定数据");
        }
      } else if (num == 1) {
        this.flagNum = 0;
        // if (this.fnote != '' && this.fstatus == '未提交') {
        if (this.fnote != "" && this.fstatus == "未提交") {
          this.disabledText = false;
          this.edit(1);
        } else {
          this.$message.error("请选择可编辑数据");
        }
      }
    },
    submitForm() {
      this.$refs.formData.validate(async (valid) => {
        if (valid) {
          if (this.fPhotofilelist.length == 0) {
            this.$refs.fPhotofilelist.style.border = "1px solid red";
          } else if (this.fSourcefilelist.length == 0) {
            this.$refs.fSourcefilelist.style.border = "1px solid red";
          } else {
            saveConcreteChecksampleEasyTest(this.formData)
              .then((res) => {
                if (res.errcode == 0) {
                  this.reload();
                  this.$message.success("新增成功");
                } else {
                  this.$message.error("新增失败", res.msg);
                }
              })
              .catch(() => {
                console.log("新增失败");
              });
          }
        } else {
          this.$message.error("请填写必填项");
        }
      });
    },

    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        this.$confirm("是否继续提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            submitConcreteChecksampleEasyTest({
              fId: id,
              userId: this.userInfo.userId,
              userName: this.userInfo.realName,
            })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.getDataList(this.getList);
                  this.$message.success("提交成功");
                } else {
                  this.$message.error("提交失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("提交失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消提交");
          });
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },
    // 删除this.equipmentDetailId
    rowDelete(id) {
      if (id != "" && id != null) {
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            delConcreteChecksampleEasyTest({ fId: id })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.getDataList(this.getList);
                  this.$message.success("删除成功");
                } else {
                  this.$message.error("删除失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("删除失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消删除");
          });
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },
    // 关闭
    resetFormv() {
      this.dialogTableVisible = false;
      this.getDataList(this.getList);
    },
    resetForms() {
      this.dialogTableVisibleDivide = false;
    },

    // 点击当前行
    getRowInfo(e) {
      this.fnote = e.F_Note;
      this.fstatus = e.F_Status;
      this.fProjecttypeid = e.F_EnCode;
      this.formData.fProjecttypeid = e.F_EnCode;
      this.row = e;
      this.equipmentDetailId = e.F_Id;
    },
    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      // var w = document.documentElement.clientWidth; //获取页面可见高度
      this.dialogHeight = h * 0.5 + "px";
      this.dialogHeights = h * 0.888 + "px";
      this.dialogHeightSample = h * 0.4 + "px";
    },
  },
};
</script>

<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

a {
  text-decoration: none;
  color: #000;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.text_table {
  width: 100%;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.block {
  /* height: 50px; */
  position: fixed;
  padding: 5px 10px;
  width: calc(100vw - 241px);
  bottom: 15px;
  display: flex;
  justify-content: space-between;
  /* align-items: center; */
  border-top: 1px solid #ebeef5;
}

.pageFlagText {
  color: #171a1d;
  font-size: 16px;
}
</style>